package com.beone.smart.smartBeauty.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.beone.smart.smartBeauty.model.dto.SleepMeasureDto;
import com.beone.smart.smartBeauty.model.entity.SleepInfoRecordDO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
public interface SleepInfoRecordDao extends BaseMapper<SleepInfoRecordDO> {
    @Select("select count(*) as times,max(score) as topScore,MIN(score) as miniScore from sleep_info where userId =#{uid}")
    SleepMeasureDto getTopAndTimes(@Param("uid") String uid);

    @Select("select * from sleep_info where userId= #{uid} ORDER BY recordDate desc  limit 1")
    SleepInfoRecordDO getLastRecord(@Param("uid") String uid);
}
